$(function() {
	$.http({
		url: "http://120.27.209.174:1010/api/v1/posts_banner",
	}).then(res => {
		res.forEach(function(item, index) {
			console.log(item, index)
			$(`<div class="carousel-item ${ index === 0 ? 'active' : '' }">
			  <img src="${ item.image }" class="d-block w-100" alt="...">
			  <div class="carousel-caption d-none d-md-block">
				<p>${ item.text }</p>
			  </div>
			</div>`).appendTo(".my-banner .carousel-inner")
			
			$(`<li data-target="#carousel" data-slide-to="${index}" class="${ index === 0 ? 'active' : '' }"></li>`).appendTo(".my-banner .carousel-indicators")
		})
	}).catch(err => {
		$(`<div class="alert alert-danger" role="alert">
		  网络错误，请刷新重试！
		</div>`).prependTo("main")
		setTimeout(() => {
			$(".alert.alert-danger").remove()
		}, 2000)
	})
})


